Skip to content

feat(vue): add a pages/_app.ts setup hook for Vue plugins - #936

Draft
hyfdev wants to merge 1 commit into
mainfrom
feat/vue-app-setup
Draft

hyfdev wants to merge 1 commit into
mainfrom
feat/vue-app-setup

Conversation

@hyfdev

@hyfdev hyfdev commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Vue Pages has no app-level hook for installing Vue plugins such as Pinia and vue-i18n.

Void now calls a function default-exported from pages/_app.ts or pages/_app.js with every Vue app it creates, on the server and in the browser, islands included.

// pages/_app.ts
import { createPinia } from 'pinia';
import type { App } from 'vue';

export default function setup(app: App) {
  const pinia = createPinia();
  app.use(pinia);
  return {
    dehydrate: () => pinia.state.value,
    hydrate(state: typeof pinia.state.value) {
      pinia.state.value = state;
    },
  };
}

For pages that hydrate and for each interactive island that renders, Void serializes what dehydrate() returns after server rendering and passes it to hydrate() before each browser app mounts.

Only a function written directly as the default export counts, so an existing pages/_app.ts helper that exports anything else stays a private module.

Setup must be synchronous; an async setup fails with pages/_app setup must be synchronous.

A server render error returns the same response as without _app.ts, and an errorHandler installed by setup also receives it.

Fixes #915

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://feat-vue-app-setup-void-cloud.voidzero-docs.workers.dev (commit bd6b377)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://d93c0401-void-cloud.voidzero-docs.workers.dev bd6b377 2026-11-27T00:30:26.942Z Visit the dashboard ↗

@hyfdev
hyfdev marked this pull request as ready for review November 27, 2026 00:40
Copilot AI balanced review requested due to automatic review settings November 27, 2026 00:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

official way to install Vue plugins (app.use) in Pages apps

2 participants